# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: omni <omni+alpine@hack.org>
maintainer="omni <omni+alpine@hack.org>"
pkgname=pegtl
_pkgname=PEGTL
pkgver=3.2.8
pkgrel=0
pkgdesc="Parsing Expression Grammar Template Library"
url="https://github.com/taocpp/PEGTL"
license="MIT"
arch="noarch"
makedepends="cmake"
subpackages="$pkgname-doc"
source="$_pkgname-$pkgver.tar.gz::https://github.com/taocpp/PEGTL/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DPEGTL_INSTALL_DOC_DIR=share/doc/$pkgname \
		-DPEGTL_INSTALL_CMAKE_DIR=lib/cmake/$pkgname \
		-DPEGTL_BUILD_TESTS=ON \
		-DPEGTL_BUILD_EXAMPLES=OFF
	cmake --build build
}

check() {
	cd build
	ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -dm0755 "$pkgdir"/usr/share/licenses/
	mv "$pkgdir"/usr/share/doc/"$pkgname" "$pkgdir"/usr/share/licenses/
	install -Dm0644 doc/* -t "$pkgdir"/usr/share/doc/"$pkgname"/
}

sha512sums="
aecf9396edbdd65549603484d1841cd676b197d164ee2979ee5acaf657da4fa9ebc1a59fc8550cfa440ce27794cdc59cdf86a6521e4bda084c0600cb2c92f5cf  PEGTL-3.2.8.tar.gz
"
